<?php
namespace App\Libs\Tools;

class ZTree{

    public static function convert_department_transform_to_tree(array $transform){
        $tree_datas=array(['id'=>'0','pId'=>'-1','name'=>'所有部门']);
        foreach ($transform['data'] as $item){
            $tree_data=[];
            $tree_data['id']=$item['id'];
            $tree_data['pId']=$item['parent_id'];
            $tree_data['name']=$item['name'];
            array_push($tree_datas,$tree_data);
        }
        return $tree_datas;
    }

    public static function convert_station_class_transform_to_tree(array $transform){
        $tree_datas=array(['id'=>'0','pId'=>'-1','name'=>'所有分类']);
        foreach ($transform['data'] as $item){
            $tree_data=[];
            $tree_data['id']=$item['id'];
            $tree_data['pId']='0';
            $tree_data['name']=$item['name'];
            array_push($tree_datas,$tree_data);
        }
        return $tree_datas;
    }
}

